import { useDetail, useList } from "@/hooks";
import { getUserInfoUrl, getUserTypeValue } from "@/command/apiTool";
import { reactive, ref, watch } from "vue";
import { getAction } from "@/command/netTool";
import * as vant from "vant";
const { showFailToast, showSuccessToast } = vant;
export const useRequest = () => {
  const form = reactive({title:'',areaCode:'',time:'',type:''});
  // 我的品牌
  const [myBrandInfo] = useDetail(
    getUserInfoUrl({
      dh: "/api/H5/richMeansOfAgriculturalProduction/large/queryMsg",
      xh: "",
    }),
    {
      address: "",
      entityName: "",
      id: "",
      logo: "",
      nz: "",
      entityContent:''
    }
  );
  

  const [ApplyList,ApplyListControl] = useDetail(
    getUserInfoUrl({
      dh: "/api/H5/richMeansOfAgriculturalProduction/large/queryApplyList",
      xh: "",
    },form),
    [
      {
        address: "",
      applyName: "",
      flag: "",
      headPath: "",
      id: "",
      phone: "",
      productionName: "",
      quantity: 2,

    }
    ]
  );
  watch(form,(e)=>{
    ApplyListControl.refresh();
  })


  const buttonAction =(id: any,status: number)=>{
    getAction(
      "/api//H5/richMeansOfAgriculturalProduction/large/accept",
      { ...{applyNo:id,status:status} },
      { isResolve: true }
    ).then((e) => {
      console.log("eee", e);
      showSuccessToast("操作成功!");
      // 刷新接口
      ApplyListControl.refresh();
    });
  }
  const confirmAccess =(e:any)=>{
    buttonAction(e.id,1)
  }

  const confirmRefuse = (e:any)=>{
    buttonAction(e.id,2)
    
  }

  
  
  

  return {
    myBrandInfo,confirmAccess,confirmRefuse,form,ApplyList
  };
};
